<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0,viewport-fit=cover"><title>Tomcat Session机制 | flyingzc's blog</title><meta name="author" content="flyingzc"><meta name="copyright" content="flyingzc"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="tomcat session相关类12345org.apache.catalina.ManagerStandardManagerSessionIdGenerator  Manager实现类Manager 用于管理 session.默认实现是 StandardManager,基类 ManagerBase. 123456789101112Manager    ClusterManager (org.a">
<meta property="og:type" content="article">
<meta property="og:title" content="Tomcat Session机制">
<meta property="og:url" content="https://flyingzc.github.io/articles/tomcat/tomcat03-session.html">
<meta property="og:site_name" content="flyingzc&#39;s blog">
<meta property="og:description" content="tomcat session相关类12345org.apache.catalina.ManagerStandardManagerSessionIdGenerator  Manager实现类Manager 用于管理 session.默认实现是 StandardManager,基类 ManagerBase. 123456789101112Manager    ClusterManager (org.a">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://flyingzc.github.io/images/zc-icon.jpeg">
<meta property="article:published_time" content="2019-12-19T16:00:00.000Z">
<meta property="article:modified_time" content="2025-01-21T01:51:41.215Z">
<meta property="article:author" content="flyingzc">
<meta property="article:tag" content="Tomcat">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://flyingzc.github.io/images/zc-icon.jpeg"><script type="application/ld+json">{
  "@context": "https://schema.org",
  "@type": "BlogPosting",
  "headline": "Tomcat Session机制",
  "url": "https://flyingzc.github.io/articles/tomcat/tomcat03-session.html",
  "image": "https://flyingzc.github.io/images/zc-icon.jpeg",
  "datePublished": "2019-12-19T16:00:00.000Z",
  "dateModified": "2025-01-21T01:51:41.215Z",
  "author": [
    {
      "@type": "Person",
      "name": "flyingzc",
      "url": "https://flyingzc.github.io/"
    }
  ]
}</script><link rel="shortcut icon" href="/images/zc-icon.jpeg"><link rel="canonical" href="https://flyingzc.github.io/articles/tomcat/tomcat03-session.html"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><meta name="google-site-verification" content="DentpX3LnP_WNgEeFnNIcTZZky-Bby-zL-uI_9GqTAw"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css"><script>
    (() => {
      
    const saveToLocal = {
      set: (key, value, ttl) => {
        if (!ttl) return
        const expiry = Date.now() + ttl * 86400000
        localStorage.setItem(key, JSON.stringify({ value, expiry }))
      },
      get: key => {
        const itemStr = localStorage.getItem(key)
        if (!itemStr) return undefined
        const { value, expiry } = JSON.parse(itemStr)
        if (Date.now() > expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return value
      }
    }

    window.btf = {
      saveToLocal,
      getScript: (url, attr = {}) => new Promise((resolve, reject) => {
        const script = document.createElement('script')
        script.src = url
        script.async = true
        Object.entries(attr).forEach(([key, val]) => script.setAttribute(key, val))
        script.onload = script.onreadystatechange = () => {
          if (!script.readyState || /loaded|complete/.test(script.readyState)) resolve()
        }
        script.onerror = reject
        document.head.appendChild(script)
      }),
      getCSS: (url, id) => new Promise((resolve, reject) => {
        const link = document.createElement('link')
        link.rel = 'stylesheet'
        link.href = url
        if (id) link.id = id
        link.onload = link.onreadystatechange = () => {
          if (!link.readyState || /loaded|complete/.test(link.readyState)) resolve()
        }
        link.onerror = reject
        document.head.appendChild(link)
      }),
      addGlobalFn: (key, fn, name = false, parent = window) => {
        if (!false && key.startsWith('pjax')) return
        const globalFn = parent.globalFn || {}
        globalFn[key] = globalFn[key] || {}
        globalFn[key][name || Object.keys(globalFn[key]).length] = fn
        parent.globalFn = globalFn
      }
    }
  
      
      const activateDarkMode = () => {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      const activateLightMode = () => {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }

      btf.activateDarkMode = activateDarkMode
      btf.activateLightMode = activateLightMode

      const theme = saveToLocal.get('theme')
    
          theme === 'dark' ? activateDarkMode() : theme === 'light' ? activateLightMode() : null
        
      
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        document.documentElement.classList.toggle('hide-aside', asideStatus === 'hide')
      }
    
      
    const detectApple = () => {
      if (/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)) {
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
  
    })()
  </script><script async="async" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><script>(adsbygoogle = window.adsbygoogle || []).push({
  google_ad_client: '',
  enable_page_level_ads: 'true'
});</script><script>const GLOBAL_CONFIG = {
  root: '/',
  algolia: undefined,
  localSearch: undefined,
  translate: undefined,
  highlight: {"plugin":"highlight.js","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false,"highlightFullpage":false,"highlightMacStyle":false},
  copy: {
    success: '复制成功',
    error: '复制失败',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  dateSuffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'null',
  Snackbar: undefined,
  infinitegrid: {
    js: 'https://cdn.jsdelivr.net/npm/@egjs/infinitegrid/dist/infinitegrid.min.js',
    buttonText: '加载更多'
  },
  isPhotoFigcaption: false,
  islazyloadPlugin: false,
  isAnchor: false,
  percent: {
    toc: true,
    rightside: false,
  },
  autoDarkmode: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'Tomcat Session机制',
  isHighlightShrink: false,
  isToc: true,
  pageType: 'post'
}</script><link rel="stylesheet" href="/self/github-dark.css"><meta name="generator" content="Hexo 7.0.0"></head><body><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img text-center"><img src="/images/zc-icon.jpeg" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data text-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">84</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">36</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">29</div></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于我</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header"><nav id="nav"><span id="blog-info"><a class="nav-site-title" href="/"><span class="site-name">flyingzc's blog</span></a><a class="nav-page-title" href="/"><span class="site-name">Tomcat Session机制</span></a></span><div id="menus"><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于我</span></a></div></div><div id="toggle-menu"><span class="site-page"><i class="fas fa-bars fa-fw"></i></span></div></div></nav><div id="post-info"><h1 class="post-title">Tomcat Session机制</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2019-12-19T16:00:00.000Z" title="发表于 2019-12-20 00:00:00">2019-12-20</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2025-01-21T01:51:41.215Z" title="更新于 2025-01-21 09:51:41">2025-01-21</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/Tomcat/">Tomcat</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title=""><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">浏览量:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="container post-content" id="article-container"><h1 id="tomcat-session"><a href="#tomcat-session" class="headerlink" title="tomcat session"></a>tomcat session</h1><h2 id="相关类"><a href="#相关类" class="headerlink" title="相关类"></a>相关类</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs plaintext">org.apache.catalina.Manager<br><br>StandardManager<br><br>SessionIdGenerator<br></code></pre></td></tr></table></figure>

<h2 id="Manager实现类"><a href="#Manager实现类" class="headerlink" title="Manager实现类"></a>Manager实现类</h2><p>Manager 用于管理 session.默认实现是 StandardManager,基类 ManagerBase.</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><code class="hljs plaintext">Manager<br>    ClusterManager (org.apache.catalina.ha)<br>        ClusterManagerBase (org.apache.catalina.ha.session)<br>            BackupManager (org.apache.catalina.ha.session)<br>            DeltaManager (org.apache.catalina.ha.session)<br>    ManagerBase (org.apache.catalina.session)<br>        PersistentManagerBase (org.apache.catalina.session)<br>            PersistentManager (org.apache.catalina.session)<br>        ClusterManagerBase (org.apache.catalina.ha.session)<br>            BackupManager (org.apache.catalina.ha.session)<br>            DeltaManager (org.apache.catalina.ha.session)<br>        StandardManager (org.apache.catalina.session)<br></code></pre></td></tr></table></figure>

<h2 id="StandardManager的实现"><a href="#StandardManager的实现" class="headerlink" title="StandardManager的实现"></a>StandardManager的实现</h2><p>通过 SessionIdGenerator 为每个会话生成,分配一个唯一标识.若集群环境,可配置后面加上tomcat集群标识.</p>
<p>过期会话处理,在 backgroundProcess() 中.它不断循环判断所有会话中是否有过期的,一旦过期则移除.</p>
<p>StandContext 停止时,将该 web 应用的所有 session 持久化到磁盘中,文件名 SESSIONS.ser.</p>
<p>当 web 应用启动时,会加载这些持久化的会话,加载完成后,SESSIONS.ser 将会被删除.</p>
<h3 id="session获取和创建"><a href="#session获取和创建" class="headerlink" title="session获取和创建"></a>session获取和创建</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><code class="hljs plaintext">- request.getSession(true)获取session对象,true表示没有则创建session<br>    - RequestFacade.getSession()<br>        - connector.Request.getSession()<br>            - doGetSession()<br>            - 1.获取StandContext<br>            - 2.若session不为null,则isValid()校验session是否失效,校验通过直接返回session<br>            - 3.若上面没有获取到session,则尝试根据requestedSessionId通过manager.findSession()去查找session<br>            - 4.manager.createSession(sessionId)创建session<br>                - 1.超过最大允许创建的session数量则报错<br>                - 2.createEmptySession()创建standardSession对象并设置session超时时间等参数<br>                - 3.generateSessionId()通过sessionIdGenerator生成sessionId设置到session.id属性中<br>            - 5.基于刚刚创建的session创建一个新的cookie,其实就是向响应头中添加Set-Cookie: JSESSIONID=AA97BC74DD24D2423386C81DB98CED8B; Path=/books; HttpOnly<br></code></pre></td></tr></table></figure>

<p><img src="https://gitee.com/flyingzc/MyImg/raw/master/img/tomcat/chrome%E4%B8%AD%E6%9F%A5%E7%9C%8B%E7%94%9F%E6%88%90%E7%9A%84cookie.png" alt="chrome中查看生成的cookie"></p>
<p><img src="https://gitee.com/flyingzc/MyImg/raw/master/img/tomcat/%E8%AF%B7%E6%B1%82%E5%A4%B4%E5%92%8C%E5%93%8D%E5%BA%94%E5%A4%B4%E4%B8%AD%E7%9A%84cookie%E7%9B%B8%E5%85%B3%E4%BF%A1%E6%81%AF.png" alt="请求头和响应头中的cookie相关信息"></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs plaintext">- session.setAttribute(KEY, username)设置session属性<br>    - StandardSessionFacade.setAttribute()<br>        - StandSession.setAttribute()<br>            - 保存key-value到protected ConcurrentMap&lt;String, Object&gt; attributes = new ConcurrentHashMap&lt;String, Object&gt;();里<br></code></pre></td></tr></table></figure>

<h3 id="session清理"><a href="#session清理" class="headerlink" title="session清理"></a>session清理</h3><p><img src="https://gitee.com/flyingzc/MyImg/raw/master/img/tomcat/backgroundProcessor%E5%90%8E%E5%8F%B0%E6%B8%85%E7%90%86session%E7%BA%BF%E7%A8%8B%E8%B0%83%E7%94%A8%E6%A0%88.png" alt="backgroundProcessor后台清理session线程调用栈"></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><code class="hljs plaintext">- ConatinerBase$ContainerBackgroundProcessor.run()<br>    - StandContext.backgroundProcess()<br>        - 父类 ContainerBase 逻辑,判断 Manager 不为 null,调用 manager.backgroundProcess().<br>            - manager.backgroundProcess()控制默认60s才执行一次清理.调用ManagerBase.processExpires()<br>                - ManagerBase.processExpires()中<br>                - 1.获取所有sessions<br>                - 2.遍历每一个session,通过isValid()判断是否失效并处理失效<br>                    - isValid()里通过当前时间戳,thisAccessedTime,maxInactiveInterval决定是否需要session失效,若失效调用expire()处理<br>                        - expire()会调用相关sessionListeners,并从ManagerBase里sessions这个map中移除session<br></code></pre></td></tr></table></figure>

<p>session thisAccessedTime 更新时机.<br>在 StandardSession.thisAccessedTime 属性上 添加 field watchpoint<br>创建session 时默认 thisAccessedTime 值 就是 creationTime<br><img src="https://gitee.com/flyingzc/MyImg/raw/master/img/tomcat/Request%E5%9B%9E%E6%94%B6session%E8%B0%83%E7%94%A8%E6%A0%88.png" alt="Request回收session调用栈"></p>
<ol>
<li><p>tomcat 在处理完请求之后,会对 Request 对象进行回收,并且会回收 Session,此时会更新 thisAccessedTime</p>
</li>
<li><p>request.getSession()时,若创建 session,会在 StandardSession.setCreationTime()里更新 thisAccessedTime.若是获取session,会在 StandardSession.access() 里更新 thisAccessedTime 为 当前时间.</p>
</li>
</ol>
<link rel="stylesheet" href="https://fastly.jsdelivr.net/npm/markmap-toolbar@0.18.10/dist/style.css"><script src="https://fastly.jsdelivr.net/npm/d3@7"></script><script src="https://fastly.jsdelivr.net/npm/markmap-view@0.18.10"></script><script src="https://fastly.jsdelivr.net/npm/markmap-toolbar@0.18.10"></script>
<link rel="stylesheet" href="/css/markmap.css">

<script src="/js/markmap.js"></script>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta"><i class="fas fa-circle-user fa-fw"></i>文章作者: </span><span class="post-copyright-info"><a href="https://flyingzc.github.io">flyingzc</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta"><i class="fas fa-square-arrow-up-right fa-fw"></i>文章链接: </span><span class="post-copyright-info"><a href="https://flyingzc.github.io/articles/tomcat/tomcat03-session.html">https://flyingzc.github.io/articles/tomcat/tomcat03-session.html</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta"><i class="fas fa-circle-exclamation fa-fw"></i>版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来源 <a href="https://flyingzc.github.io" target="_blank">flyingzc's blog</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/Tomcat/">Tomcat</a></div><div class="post-share"><div class="social-share" data-image="/images/zc-icon.jpeg" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span>相关推荐</span></div><div class="relatedPosts-list"><a class="pagination-related" href="/articles/tomcat/tomcat01-lifecycle.html" title="Tomcat Lifecycle"><div class="cover" style="background: var(--default-bg-color)"></div><div class="info text-center"><div class="info-1"><div class="info-item-1"><i class="far fa-calendar-alt fa-fw"></i> 2019-12-19</div><div class="info-item-2">Tomcat Lifecycle</div></div><div class="info-2"><div class="info-item-1">LifeCycleLifeCycle 相关类LifeCycle 接口中的状态扭转注释,如下: 12345678910111213141516171819202122232425262728*            start()*  -----------------------------*  |                           |*  | init()                    |* NEW -»-- INITIALIZING        |* | |           |              |     ------------------«-----------------------* | |           |auto          |     |                                        |* | |          \|/    start() \|/   \|/     auto          auto         stop() |* | |     ...</div></div></div></a><a class="pagination-related" href="/articles/tomcat/tomcat01_debug.html" title="Tomcat Debug"><div class="cover" style="background: var(--default-bg-color)"></div><div class="info text-center"><div class="info-1"><div class="info-item-1"><i class="far fa-calendar-alt fa-fw"></i> 2019-11-29</div><div class="info-item-2">Tomcat Debug</div></div><div class="info-2"><div class="info-item-1">tomcat debug方式1. tomcat远程debug,这种方式正常用于sit或者灰度环境调试问题使用,当然localhost也能这样debug.在 startup.sh 中配置 1SET CATALINA_OPTS=-server -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=19999  方式2. 在idea中启动tomcat debug,需要添加tomcat的jar依赖.这种方式用于本地看tomcat源码或者定位本地起的项目中tomcat部分的问题时可以使用. 12345678910111213&lt;dependency&gt;    &lt;groupId&gt;org.apache.tomcat&lt;/groupId&gt;    &lt;artifactId&gt;tomcat-catalina&lt;/artifactId&gt;    &lt;version&gt;7.0.82&lt;/version&gt;...</div></div></div></a><a class="pagination-related" href="/articles/tomcat/tomcat02-start.html" title="Tomcat启动流程"><div class="cover" style="background: var(--default-bg-color)"></div><div class="info text-center"><div class="info-1"><div class="info-item-1"><i class="far fa-calendar-alt fa-fw"></i> 2019-12-19</div><div class="info-item-2">Tomcat启动流程</div></div><div class="info-2"><div class="info-item-1">tomcat...</div></div></div></a><a class="pagination-related" href="/articles/tomcat/tomcat04-distribute-session.html" title="Tomcat实现分布式session"><div class="cover" style="background: var(--default-bg-color)"></div><div class="info text-center"><div class="info-1"><div class="info-item-1"><i class="far fa-calendar-alt fa-fw"></i> 2019-12-20</div><div class="info-item-2">Tomcat实现分布式session</div></div><div class="info-2"><div class="info-item-1">tomcat实现分布式sessiontomcat-redis-session-manager 使用Copy the following files into the TOMCAT_BASE&#x2F;lib directory: 123tomcat-redis-session-manager-VERSION.jarjedis-2.5.2.jarcommons-pool2-2.2.jar  配置 TOMCAT_HOME&#x2F;conf&#x2F;context.xml 12345&lt;Valve className=&quot;com.radiadesign.catalina.session.RedisSessionHandlerValve&quot; /&gt;&lt;Manager className=&quot;com.radiadesign.catalina.session.RedisSessionManager&quot;         host=&quot;localhost&quot;            port=&quot;6379&quot;...</div></div></div></a><a class="pagination-related" href="/articles/tomcat/tomcat06-request.html" title="Tomcat处理请求流程"><div class="cover" style="background: var(--default-bg-color)"></div><div class="info text-center"><div class="info-1"><div class="info-item-1"><i class="far fa-calendar-alt fa-fw"></i> 2019-12-26</div><div class="info-item-2">Tomcat处理请求流程</div></div><div class="info-2"><div class="info-item-1">tomcat处理请求组件Server123456789101112131415Server|-- Service|--|-- Connector|--|--|-- Prototal|--|--|--|-- Endpoint|--|--|--|--|-- Acceptor|--|--|--|--|-- Executor|--|--|--|-- Processor|--|--|-- Mapper|--|--|-- CoyteAdapter|--|-- Container|--|--|--|-- Host|--|--|--|-- Context|--|--|--|-- Wrapper|--|-- Executor  Http11NioProtocol12345678910111213Http11NioProtocol|-- NioEndpoint|--|-- LimitLatch|--|-- Acceptor|--|-- Poller|--|-- Poller池|--|-- SocketProcessor|--|-- Executor|--|-- PollerEvent|--|--...</div></div></div></a></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info text-center"><div class="avatar-img"><img src="/images/zc-icon.jpeg" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info-name">flyingzc</div><div class="author-info-description">不积跬步无以至千里<br/>不积小流无以成江海</div><div class="site-data"><a href="/archives/"><div class="headline">文章</div><div class="length-num">84</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">36</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">29</div></a></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/FlyingZC"><i class="fab fa-github"></i><span>Follow Me</span></a><div class="card-info-social-icons"><a class="social-icon" href="https://github.com/FlyingZC" target="_blank" title="Github"><i class="fab fa-github" style="color: #24292e;"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content">FlyingZC's Blog</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#tomcat-session"><span class="toc-number">1.</span> <span class="toc-text">tomcat session</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%9B%B8%E5%85%B3%E7%B1%BB"><span class="toc-number">1.1.</span> <span class="toc-text">相关类</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Manager%E5%AE%9E%E7%8E%B0%E7%B1%BB"><span class="toc-number">1.2.</span> <span class="toc-text">Manager实现类</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#StandardManager%E7%9A%84%E5%AE%9E%E7%8E%B0"><span class="toc-number">1.3.</span> <span class="toc-text">StandardManager的实现</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#session%E8%8E%B7%E5%8F%96%E5%92%8C%E5%88%9B%E5%BB%BA"><span class="toc-number">1.3.1.</span> <span class="toc-text">session获取和创建</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#session%E6%B8%85%E7%90%86"><span class="toc-number">1.3.2.</span> <span class="toc-text">session清理</span></a></li></ol></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/articles/ignite/ignite03-transaction-begin.html" title="Apache Ignite 开启事务执行流程">Apache Ignite 开启事务执行流程</a><time datetime="2025-10-10T16:00:00.000Z" title="发表于 2025-10-11 00:00:00">2025-10-11</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/articles/ignite/ignite02-transaction.html" title="Apache Ignite 分布式事务原理">Apache Ignite 分布式事务原理</a><time datetime="2025-09-17T16:00:00.000Z" title="发表于 2025-09-18 00:00:00">2025-09-18</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/articles/ignite/ignite01-build.html" title="Apache Ignite IDEA 环境搭建">Apache Ignite IDEA 环境搭建</a><time datetime="2025-09-10T16:00:00.000Z" title="发表于 2025-09-11 00:00:00">2025-09-11</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/articles/druid/druid01-resultset-leak.html" title="ShardingSphere JDBC 使用 Druid 连接池 ResultSet 内存泄露分析">ShardingSphere JDBC 使用 Druid 连接池 ResultSet 内存泄露分析</a><time datetime="2025-06-30T16:00:00.000Z" title="发表于 2025-07-01 00:00:00">2025-07-01</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/articles/jmeter/jmeter01-shardingsphere.html" title="Jmeter 压测 ShardingSphere">Jmeter 压测 ShardingSphere</a><time datetime="2025-06-30T16:00:00.000Z" title="发表于 2025-07-01 00:00:00">2025-07-01</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2025 By flyingzc</div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="日间和夜间模式切换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside-config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><span class="scroll-percent"></span><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><div class="js-pjax"></div><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div></body></html>